import { BaseSkill } from '../BaseSkill';
import { DamageType, SkillType } from '../../types';
import { General } from '../../models/General';
import { Battle } from '../../models/Battle';

export class ShenSu extends BaseSkill {
  private readonly INITIATIVE_BOOST = 100;
  private usageCount = 0;
  private readonly MAX_USES = 2;

  constructor() {
    super(
      'shenSu',
      '神速',
      SkillType.Passive,
      DamageType.None,
      0.4,  // 40% 触发概率
      0,    // 无CD
      1     // 1回合持续
    );
  }

  execute(source: General, battle: Battle): void {
    if (this.usageCount >= this.MAX_USES || Math.random() > this.probability) return;

    source.addEffect({
      type: 'initiative',
      value: this.INITIATIVE_BOOST,
      duration: this.duration,
      stackable: false
    });

    this.usageCount++;
  }

  resetCounter(): void {
    this.usageCount = 0;
  }
}
